import http from '../service/http';
// import store from '../store';


// 获取购物车列表

export function getShopCarList() {
    return http({
        url: '/cart/list',
        method: 'get',
        params: {
            id: 1,
        },
        headers: {
            authorization: sessionStorage.getItem('token'),

        },

    });
    

}

// 单选框
export function updateone(id,goodsId) {
    return http({
        url: '/cart/select',
        method: 'post',
        data: {
            id, 
            goodsId 
        },
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            authorization: sessionStorage.getItem('token'),

        },

    });
}

// 全选
export function updateall(id) {
    return http({
        url: '/cart/select/all',
        method: 'post',
        data: {
            id, 
            type: '1' 
        },
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            authorization: sessionStorage.getItem('token'),

        },

    });
}
// 删除单个商品
export function deleteShopCar(id,goodsId) {
    return http({
        url: '/cart/remove',
        method: 'get',
        params: {
            id,
            goodsId
        },
        headers: {
            // 'Content-Type': 'application/x-www-form-urlencoded',
            authorization: sessionStorage.getItem('token'),

        },

    });
}


// 清空购物车
export function clearallCar(id) {
    return http({
        url: '/cart/clear',
        method: 'get',
        params: {
            id,
        },
        headers: {
            // 'Content-Type': 'application/x-www-form-urlencoded',
            authorization: sessionStorage.getItem('token'),

        },

    });
}


// 支付接口
export function settlement(id) {
    return http({
        url: 'cart/pay',
        method: 'post',
        data: {
            id,  
        },
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            authorization: sessionStorage.getItem('token'),

        },

    });
}

export function updatenumber(id,goodsId,number) {
    return http({
        url: '/cart/number',
        method: 'post',
        data: {
            id, 
            goodsId, 
            number
        },
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            authorization: sessionStorage.getItem('token'),

        },

    });
}